// UI.js所在文件夹
var js = document.scripts;
var jsPath = "";
for (var i = js.length; i > 0; i--) {
	if (js[i - 1].src.indexOf("UI.js") > -1) {
		jsPath = js[i - 1].src;
	}
}
jsLen = jsPath.length - 5;
jsPath = jsPath.substr(0,jsLen);

var UI = {
	// bootscript的js插件之模态框弹窗
	alert:function(obj){

		var title = (obj && obj.title)?obj.title : '系统提示';
		var msg = (obj && obj.msg)?obj.msg : '';
		var icon = (obj && obj.icon)?obj.icon : 3;
		// 模态框主体
		var html = '<div class="modal fade" tabindex="-1" role="dialog" id="UI_alert_sm">\
					  <div class="modal-dialog modal-sm" role="document">\
					    <div class="modal-content">\
					      <div class="modal-header">\
					      	<h4 class="modal-title">'+title+'</h4>\
					        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\
					      </div>\
					      <div class="modal-body">\
					        <p><img src="'+jsPath+'/img/'+icon+'.png" style="width:32px;height:32px;margin-right:5px;">'+msg+'</p>\
					      </div>\
					      <div class="modal-footer">\
					        <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>\
					      </div>\
					    </div>\
					  </div>\
					</div>';
		// 在body末尾插入模态框
		$('body').append(html);
		// 禁用点击空白处消失的效果
		$('#UI_alert_sm').modal({backdrop:'static'});
		// 弹出模态框
		$('#UI_alert_sm').modal('show');
		// 隐藏模态框后在页面上移除
		$('#UI_alert_sm').on('hidden.bs.modal', function (e) {
			$('#UI_alert_sm').remove();
		});
	},

	open:function(obj){
		var title = (obj == undefined || obj.title == undefined) ? '' : obj.title;
		var width = (obj == undefined || obj.width == undefined) ? 450 : obj.width;
		var height = (obj == undefined || obj.height == undefined) ? 350 : obj.height;
		var url = (obj == undefined || obj.url == undefined) ? '' : obj.url;
		var html = '<div class="modal fade" tabindex="-1" role="dialog" id="UI_open_sm">\
					  <div class="modal-dialog modal-lg" role="document">\
					    <div class="modal-content">\
					      <div class="modal-header">\
					      	<h4 class="modal-title">'+title+'</h4>\
					        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\
					      </div>\
					      <div class="modal-body">\
					      	<iframe src="'+url+'" frameborder="0" frameborder="0" style="width:100%;height:100%;"></iframe>\
					      </div>\
					    </div>\
					  </div>\
					</div>';
		// 在body末尾插入模态框
		$('body').append(html);
		// 自定义宽度
		$('#UI_open_sm .modal-lg').css('width',width);
		// 自定义高度
		$('#UI_open_sm .modal-body').css('height',height);
		// 禁用点击空白处消失的效果
		$('#UI_open_sm').modal({backdrop:'static'});
		// 弹出模态框
		$('#UI_open_sm').modal('show');
		// 隐藏模态框后在页面上移除
		$('#UI_open_sm').on('hidden.bs.modal', function (e) {
			$('#UI_open_sm').remove();
		});
	}
}